package com.example.feign.user;

import com.example.common.api.ResultUtil;
import com.example.feign.user.fallback.UserFeignFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;

@FeignClient(value = "demo-user", path = "/api", fallback = UserFeignFallback.class, decode404 = true)  //value中是调用服务的名称，这个要对应服务名称
public interface UserFeignClient {

    @GetMapping(value = "/user/get_user", produces = MediaType.APPLICATION_JSON_VALUE)
    @ResponseBody
    ResultUtil getUser(@RequestParam(required = false, name = "mobile") String mobile,
                       @RequestParam(required = false, name = "password") String password);

    @GetMapping(value = "/address/get_address_by_id/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
    @ResponseBody
    ResultUtil getAddressById(@PathVariable(value = "id") Long id);


    @GetMapping(value = "/address/get_address_by_user_id/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
    @ResponseBody
    ResultUtil getAddressByUserId(@PathVariable(value = "id") Long id);
}
